package com.holly.unit.bpmn.designer.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.util.Objects;

/**
 * 类描述: 基础信息
 *
 * @author fxr
 * @version 1.0.0
 * @date 2022/5/12 8:18
 */
@Getter
@Setter
@Accessors(chain = true)
public class BasicInfo {

    /** 流程名称 */
    @JsonProperty("flowName")
    private String flowName;

    /** 流程图标 */
    @JsonProperty("flowIcon")
    private String flowIcon;

    /** 流程图标背景 */
    @JsonProperty("flowIconBackground")
    private String flowIconBackground;

    /** 流程分组 */
    @JsonProperty("flowGroup")
    private Integer flowGroup;

    /** 流程说明 */
    @JsonProperty("flowRemark")
    private String flowRemark;

    /** 流程编码 */
    @JsonProperty("flowCode")
    private String flowCode;

    /***
     * 主键id
     */
    @JsonProperty("id")
    private String id;

    public static Builder builder() {
        return new Builder();
    }

    public static class Builder {
        private BasicInfo info;

        private Builder() {
            this.info = new BasicInfo();
        }


        public Builder id(final String id) {
            if (Objects.nonNull(id)) {
                this.info.setId(id);
            }
            return this;
        }

        public Builder code(final String flowCode) {
            if (Objects.nonNull(flowCode)) {
                this.info.setFlowCode(flowCode);
            }
            return this;
        }

        public Builder remark(final String flowRemark) {
            if (Objects.nonNull(flowRemark)) {
                this.info.setFlowRemark(flowRemark);
            } else {
                this.info.setFlowRemark("");
            }
            return this;
        }

        public Builder group(final Integer flowGroup) {
            if (Objects.nonNull(flowGroup)) {
                this.info.setFlowGroup(flowGroup);
            }
            return this;
        }

        public Builder background(final String flowIconBackground) {
            if (Objects.nonNull(flowIconBackground)) {
                this.info.setFlowIconBackground(flowIconBackground);
            }
            return this;
        }

        public Builder icon(final String flowIcon) {
            if (Objects.nonNull(flowIcon)) {
                this.info.setFlowIcon(flowIcon);
            }
            return this;
        }

        public Builder name(final String flowName) {
            if (Objects.nonNull(flowName)) {
                this.info.setFlowName(flowName);
            }
            return this;
        }

        public BasicInfo build() {
            Objects.requireNonNull(this.info.getId());
            Objects.requireNonNull(this.info.getFlowCode());
            Objects.requireNonNull(this.info.getFlowGroup());

            return this.info;
        }
    }
}
